package baseTest;

import java.util.ArrayList;
import java.util.List;

public class subsets {
    public static void main(String[] args) {
        int[] nums = {1,2,3};
        List<List<Integer>> process = process(nums);
        for (List<Integer> list:process) {
            System.out.println(list);
        }
    }

    public static List<List<Integer>> process(int[] nums){
        if (nums == null || nums.length == 0){
            return null;
        }
        List<List<Integer>> lists = new ArrayList<>();
        List<Integer> list = new ArrayList<>();
        process(nums,lists,list,0);
        return lists;
    }

    public static void process(int[] nums,List<List<Integer>> lists,List<Integer> list,int cur){
        if (nums.length == cur){
            lists.add(new ArrayList<>(list));
            return;
        }
        process(nums,lists,list,cur+1);
        list.add(nums[cur]);
        process(nums,lists,list,cur+1);
        list.remove(list.size()-1);
    }
}
